a11y: Emit focus events
authorMatthias Clasen <mclasen@redhat.com>
Tue, 20 Apr 2021 01:29:17 +0000 (21:29 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 20 Apr 2021 01:29:17 +0000 (21:29 -0400)
Orca relies on these to keep track of the focus location,
ignoring the focused state. With this change, orca can
once again speak text in entries as I type.

gtk/a11y/gtkatspicontext.c

index 9891a4da69094a95e68c2e5e2c46af3c1fd0cf5a..c15c4d37b9a27b39f9173162e6a9e521a0f35a0c 100644 (file)
@@ -864,6 +864,24 @@ emit_children_changed (GtkAtSpiContext         *self,
                                     context_ref);
 }
 
+static void
+emit_focus (GtkAtSpiContext *self,
+            gboolean         focus_in)
+{
+  if (self->connection == NULL)
+    return;
+
+  if (focus_in)
+    g_dbus_connection_emit_signal (self->connection,
+                                   NULL,
+                                   self->context_path,
+                                   "org.a11y.atspi.Event.Focus",
+                                   "Focus",
+                                   g_variant_new ("(siiva{sv})",
+                                                  "", 0, 0, g_variant_new_string ("0"), NULL),
+                                   NULL);
+}
+
 static void
 gtk_at_spi_context_state_change (GtkATContext                *ctx,
                                  GtkAccessibleStateChange     changed_states,
@@ -1091,6 +1109,7 @@ gtk_at_spi_context_platform_change (GtkATContext                *ctx,
       gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget),
                                                           GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED);
       emit_state_changed (self, "focused", state);
+      emit_focus (self, state);
     }
 
   if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE)